import Vue from 'vue'
import VueRouter from 'vue-router'

// 一级路由
import Login from '@/views/login'
import Register from '@/views/register'
import Detail from '@/views/detail'
import Layout from '@/views/layout'
import NotFound from '@/views/NotFound'
// 二级路由
import Article from '@/views/article'
import Find from '@/views/find'
import Info from '@/views/info'
import My from '@/views/my'

Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    redirect: '/layout/article'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/register',
    component: Register
  },
  {
    path: '/detail',
    component: Detail
  },
  {
    path: '*',
    component: NotFound
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/article',
    children: [
      {
        path: 'article',
        component: Article
      },
      {
        path: 'find',
        component: Find
      },
      {
        path: 'info',
        component: Info
      },
      {
        path: 'my',
        component: My
      }
    ]
  }

]

const router = new VueRouter({
  routes
})

export default router
